import { Body, Controller, Get, Param, Post, Put, Query } from '@nestjs/common';
import { JobFairsService } from './job.fairs.service';
import { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger';
import {
  CreateJobFairsDto,
  FindJobFairsDto,
  SetJobFairsCompany,
  UpdateJobFairsDto,
} from './job-fairs.dto';

@ApiTags('招聘会管理')
@ApiBearerAuth()
@Controller('job-fairs')
export class JobFairsController {
  constructor(private jobFairsService: JobFairsService) {}

  @Get('list')
  @ApiOperation({ summary: '获取招聘会列表' })
  getJobFairsList(@Query() query: FindJobFairsDto) {
    return this.jobFairsService.find(query);
  }

  @Get('detail/:id')
  @ApiOperation({ summary: '获取招聘会详细' })
  async getJobFairsCompanyList(@Param('id') id: string) {
    return await this.jobFairsService.detail(+id);
  }

  @Post('create')
  @ApiOperation({ summary: '新增招聘会' })
  createJobFairs(@Body() createJobFairsDto: CreateJobFairsDto) {
    return this.jobFairsService.create(createJobFairsDto);
  }

  @Put('update')
  @ApiOperation({ summary: '更新招聘会' })
  async updateJobFairs(@Body() updateJobFairsDto: UpdateJobFairsDto) {
    return await this.jobFairsService.update(updateJobFairsDto);
  }

  @Put('update/status/:id')
  @ApiOperation({ summary: '更新状态' })
  async updateJobFairsStatus(@Param('id') id: string) {
    return await this.jobFairsService.updateStatus(+id);
  }

  @Post('set/company')
  @ApiOperation({ summary: '设置招聘会公司' })
  jobFarisSetCompany(@Body() setJobFairsCompany: SetJobFairsCompany) {
    return this.jobFairsService.setCompany(setJobFairsCompany);
  }

  @Post('remove/company')
  @ApiOperation({ summary: '移除招聘会公司' })
  jobFarisRemoveCompany(@Body() setJobFairsCompany: SetJobFairsCompany) {
    return this.jobFairsService.removeCompany(setJobFairsCompany);
  }
}
